home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy-1.1 (sources only) / mindy-1.1 / libraries / dylan / ext.dylan < prev    next >
Encoding:
Text File  |  1994-06-28  |  2.0 KB  |  61 lines  |  [TEXT/ttxt]

  1. module: extensions
  2. rcs-header: $Header: ext.dylan,v 1.2 94/06/27 17:10:26 wlott Exp $
  3.  
  4. //======================================================================
  5. //
  6. // Copyright (c) 1994  Carnegie Mellon University
  7. // All rights reserved.
  8. // 
  9. // Use and copying of this software and preparation of derivative
  10. // works based on this software are permitted, including commercial
  11. // use, provided that the following conditions are observed:
  12. // 
  13. // 1. This copyright notice must be retained in full on any copies
  14. //    and on appropriate parts of any derivative works.
  15. // 2. Documentation (paper or online) accompanying any system that
  16. //    incorporates this software, or any part of it, must acknowledge
  17. //    the contribution of the Gwydion Project at Carnegie Mellon
  18. //    University.
  19. // 
  20. // This software is made available "as is".  Neither the authors nor
  21. // Carnegie Mellon University make any warranty about the software,
  22. // its performance, or its conformity to any specification.
  23. // 
  24. // Bug reports, questions, comments, and suggestions should be sent by
  25. // E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  26. //
  27. //======================================================================
  28. //
  29. //  This file contains some random things that don't really fit anywhere
  30. //  else.
  31. //
  32.  
  33. /// ONE-OF
  34. ///
  35. /// One-of returns a type that represents one of the argument things.  In
  36. /// other words, a union of a bunch of singletons.
  37. /// 
  38. define constant one-of =
  39.   method (thing, #rest more-things) => result :: <type>;
  40.     reduce(union, singleton(thing), map(singleton, more-things));
  41.   end;
  42.  
  43. /// TYPE-OR
  44. ///
  45. /// Type-or returns the union of all the argument types.
  46. define constant type-or =
  47.   method (type :: <type>, #rest more-types) => result :: <type>;
  48.   // Make sure all of more-types are <type>s.
  49.     do(rcurry(check-type, <type>), more-types);
  50.   // Make a union out of them.
  51.     reduce(union, type, more-types);
  52.   end;
  53.  
  54.  
  55.  
  56. define constant ignore =
  57.   method (#rest noise)
  58.     noise;
  59.     #f;
  60.   end;
  61.